'use strict'
//会话管理类(用户连接管理类)
class SessionMgr {
    constructor() {
        this.sessions = {} //保存pid对应的player
        this.sessionsUid = {} //保存uid对应的player
    }

    bind(pId, player) {
        this.sessions[pId] = player
    }

    getPlayer(pId) {
        return this.sessions[pId]
    }

    getPlayerByUid(uId) {
        return this.sessionsUid[uId]
    }


    delPlayer(pId) {
        delete this.sessions[pId]
    }
}

let sessionMgr = new SessionMgr()
module.exports = sessionMgr
